<?php require_once('header.php'); ?>
<?php //include_once('topwidget.php'); ?>
<div id="contentBox">
<?php include_once('sidebar.php'); ?>
<!--- query for signup an user to the site -->
<?php
if(isset($_POST['AddSubCat'])) {
	$scatid = $_POST['scatid'];
	$cname = $_POST['cname'];
	$cdesc = $_POST['cdesc'];
	
	$addSubCat = "INSERT INTO subcategories ( scatid, cname, cdesc) VALUES ('$scatid', '$cname', '$cdesc')";
	connection();	
	if(mysql_query($addSubCat)) {
		success();
	} else {
		failed();
	}
}
?>

<div id="content">
    <div class="form">
    <fieldset>
    	<legend><h1>Add New Sub Category</h1></legend>
        <form action="<?php phpSelf(); ?>" method="post">
            <div class="inputArea">
                <label for="input">Category</label>
                <?php
				$catquery = "SELECT * FROM categories";
				connection();
				$cats = mysql_query($catquery);
				?>
                <select name="scatid">
                <?php while($cat = mysql_fetch_assoc($cats)) { ?>
                	<option value="<?php echo $cat['cid']; ?>"><?php echo $cat['cname']; ?></option>
                <?php } ?>
                </select>                
            </div>
        
            <div class="inputArea">
                <label for="input">Sub Category Name</label>
                <input type="text" name="cname" />
            </div>
            <div class="inputArea">
                <label for="input">Category Description</label>
                <textarea name="cdesc" rows="12"></textarea>
            </div>            
            <div class="inputArea">
            	<label for="input">&nbsp;</label>
                <input class="oBtn inneroBtnPrimary" type="submit" name="AddSubCat" value="Add Sub-category" />
            </div>
        </form>
        </fieldset>
</div>
<!-- end content in bottom div -->
</div>
<div style="clear:both;"></div>

<?php //include_once('bottomwidget.php'); ?>
<?php include_once('footer.php'); ?>
